;/*=============================================================================
;#    The element-comm is a tentative program used to test our ideas.           
;#                       Copyright (C)  bgao                                    
;#
;#     This program is free software; you can redistribute it and/or            
;#      modify it under the terms of the GNU General Public License             
;#     as published by the Free Software Foundation; either version 2           
;#         of the License, or (at your option) any later version.               
;#
;#     This program is distributed in the hope that it will be useful,          
;#    but WITHOUT ANY WARRANTY; without even the implied warranty of           
;#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the            
;#             GNU General Public License for more details.                    
;#
;#    You should have received a copy of the GNU General Public License        
;#     along with this program; if not, write to the Free Software             
;#      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,             
;#                       MA  02110-1301, USA.                                  
;#==============================================================================
;# $Id$ 
;#
;# $Author$ 
;#
;# $Revision$ 
;#
;# $Date$ 
;#
;# Description: 
;#
;=============================================================================*/
	export wsn_context_switch

MODE_SVC	EQU	0x0013
MODE_USR	EQU	0x0010
I_BIT		EQU	0x0080
F_BIT		EQU	0x0040
	
	area ASMTEXT, code, readonly

wsn_context_switch
	stmfd   sp!, {r4 - r11,lr}		; Store most regs on stack
	str     sp, [r0, #0]			; Save sp_SVC 
	;mov r3, #MODE_SVC | I_BIT | F_BIT
	;msr cpsr_c, r3					; Disable interrupt
	ldr     sp, [r1, #0]			; Get saved sp_SVC 
	;mov r3, #MODE_SVC
	ldmfd   sp!, {r4 - r11,lr}		; Load all regs saved previously
	;msr cpsr_c, r3					; Enable interrupt
	;ldmfd	sp!, {pc}
	mov pc, lr

	END
	
